dnl Process this file with autoconf to produce a configure script

dnl Initialization

AC_PREREQ(2.59)

m4_define(gmatlab_version, 0.5)

m4_define(glib_required_version, 2.22.0)
m4_define(gi_required_version, 0.9.10)

AC_INIT([gmatlab], [gmatlab_version], [culbert1@illinois.edu])
AC_CONFIG_SRCDIR([src/gmatlab.h])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR(m4)
AM_INIT_AUTOMAKE([1.9 foreign])
# AC_CONFIG_HEADERS(config.h)

dnl Configure options

dnl Check for windows

AC_CANONICAL_HOST
AC_MSG_CHECKING(whether this is Windows)
case "$host_os" in
  cygwin* | mingw* | pw32*)
    IS_WINDOWS=yes
    AC_MSG_RESULT(yes)
  ;;

  *)
    IS_WINDOWS=no
    AC_MSG_RESULT(no)
  ;;
esac
AM_CONDITIONAL([WINDOWS], [test "x$IS_WINDOWS" = xyes])

dnl Required programs

AC_PROG_CC
AC_PROG_LIBTOOL
#GTK_DOC_CHECK(1.9)

dnl Check MATLAB compilation environment

AX_REQUIRE_MATLAB
#AX_REQUIRE_MATLAB_VERSION(7.6)
AX_MATLAB_ARCH
if test "${ax_cv_matlab_arch}" = unknown ; then
  AC_MSG_ERROR([Unable to determine the MATLAB architecture.
  Please specify it with the MATLAB_ARCH environment variable])
fi
MEXEXT=mex${MATLAB_ARCH}
MATLAB_CFLAGS=-I${MATLAB}/extern/include
MATLAB_LDFLAGS="-L${MATLAB}/bin/${MATLAB_ARCH} -lmx -lmex"
if test "${TOOLBOX_PREFIX}x" = x ; then
  TOOLBOX_PREFIX=${MATLAB}/toolbox
fi
AC_SUBST([TOOLBOX_PREFIX])
AC_SUBST([MEXEXT])
AC_SUBST([MATLAB_CFLAGS])
AC_SUBST([MATLAB_LDFLAGS])


dnl Required libraries

AM_PATH_GLIB_2_0(glib_required_version, :,
  AC_MSG_ERROR(Test for GLIB failed. See the file 'INSTALL' for help.),
  gobject)
GOBJECT_INTROSPECTION_REQUIRE([gi_required_version])

dnl Headers, typedefs/structures, functions

AC_CHECK_SIZEOF(int)
SIZEOF_INT=$ac_cv_sizeof_int
AC_SUBST([SIZEOF_INT])

dnl Output

AC_CONFIG_FILES([
  Makefile
  src/Makefile
  src/gmatlab-conf.h
  +glib/Makefile
  tests/Makefile
])
AC_OUTPUT
